package swingdisplay;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import entry.Entry;

public class EntriesTableModel extends AbstractTableModel {
	private static final long serialVersionUID = 1L;

	public static final int COLUMN_ABBR = 0;
	public static final int COLUMN_EXTENSION = 1;
	private List<Entry> list = new ArrayList<Entry>();

	@Override
	public int getColumnCount() {
		return 2;
	}

	@Override
	public int getRowCount() {
		return list.size();
	}

	@Override
	public Object getValueAt(int row, int column) {
		if (row >= list.size()) {
			return null;
		}
		switch (column) {
		case COLUMN_ABBR:
			return list.get(row).getAbbr();
		case COLUMN_EXTENSION:
			return list.get(row).getExtension();
			default: 
		}
		return null;
	}

	@Override
	public String getColumnName(int column) {
		switch (column) {
		case COLUMN_ABBR:
			return "Abbr";
		case COLUMN_EXTENSION:
			return "Extension";
		}
		return null;
	}
	
	public void setList(List<Entry> list){
		this.list = list;
	}

}
